package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"xialou_platform/app/middleware"
	"xialou_platform/services/system/api/internal/config"
	"xialou_platform/services/system/rpc/system"
)

type ServiceContext struct {
	Config  config.Config
	Auth    rest.Middleware
	AuthJwt rest.Middleware

	SystemRpc system.System
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:  c,
		Auth:    middleware.NewAuthMiddleware(c.Auth.AccessSecret).Handle,
		AuthJwt: middleware.NewAuthJwtMiddleware().Handle,

		SystemRpc: system.NewSystem(zrpc.MustNewClient(c.SystemRpc)),
	}
}
